package edu.cmu.ece.ds.droidchat.message;

import java.io.Serializable;

/**
 * An object that represent the response to a registration request from 
 *  the DroidChat server back to a DroidChat user
 *  
 *  a subclass of "DroidChatMessage"
 */
public class ClientRegisterResponseMessage extends DroidChatMessage implements Serializable{	
	
	// possible response codes
	public static final int USERNAME_ALREADY_REGISTERED = 1;
	public static final int REGISTER_SUCCESSFUL = 2;
	
	private int response = 0; // the response code
	private String username;
	
	public ClientRegisterResponseMessage(int response, String username) {
		super(DroidChatMessage.CLIENT_REGISTER_RESPONSE);
		this.response = response;
		this.username = username;
	}

	public String toString(){
		if(response==USERNAME_ALREADY_REGISTERED){
			return "ClientRegisterResponseMessage: REGISTRATION FAILED, username: " + username + " already registered";
		}else if(response==REGISTER_SUCCESSFUL){
			return "ClientRegisterResponseMessage: REGISTRATION SUCCEEDED, username: " + username;
		}else{
			return "ClientRegisterResponseMessage: incorrect response code ";
		}
	}

	public int getResponse()    {	return response;	}
	public String getUsername() {	return username;	}
}
